package tests;

import common.Utils;
import org.openqa.selenium.By;

import java.io.IOException;

import static tests.ShoppingCartPage.settlementUrl;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 */
public class OrderConfirmationPage extends Utils {
    public static String url = settlementUrl;

    public OrderConfirmationPage() {
        super(url);
    }
    /**
     * 检查页面
     */
    public void checkOrderConfirmationPage() throws IOException {
        //地址
        driver.findElement(By.cssSelector("#buy-items-tabs > ul > li.am-active > a"));
        //同城
        driver.findElement(By.cssSelector("#buy-items-tabs > ul > li:nth-child(2) > a"));
        //自提
        driver.findElement(By.cssSelector("#buy-items-tabs > ul > li:nth-child(3) > a"));
        //地址列表
        driver.findElement(By.cssSelector("#buy-items-address > ul"));
        //商品信息div
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div:nth-child(5) > div > div.buy-items.am-background-white.am-radius.am-padding-main.am-margin-top-main > div"));
        //买家留言输入框
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div:nth-child(5) > div > div.am-background-white.am-radius.am-padding-bottom-main > div.buy-message.am-padding-horizontal-main.am-margin-top-sm > div > div > textarea"));
        //提交订单按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div:nth-child(5) > div > div.am-background-white.am-radius.am-padding-bottom-main > div.buy-nav-footer.am-padding-horizontal-main > div > form > div > button"));
        //包含实付款、联系人、地址
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div:nth-child(5) > div > div.am-background-white.am-radius.am-padding-bottom-main > div.buy-nav-footer.am-padding-horizontal-main > div > div"));
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
    /**
     * 测试提交订单
     */
    public void submitOrder() throws IOException, InterruptedException {
        //选择发货方式
        //选择快递
        //屏幕截图
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());

        //选择同城
        driver.findElement(By.cssSelector("#buy-items-tabs > ul > li:nth-child(2) > a")).click();
        //屏幕截图
        Thread.sleep(1000);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
        driver.findElement(By.cssSelector("#buy-items-tabs > ul > li:nth-child(3) > a")).click();

        //点击“选择取货地址”
        driver.findElement(By.cssSelector("#buy-items-address > div.am-text-center > button")).click();
        driver.findElement(By.cssSelector("#extraction-address-popup > div > div.am-popup-bd > ul > li:nth-child(1) > div > button")).click();
        //屏幕截图
        Thread.sleep(3000);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
        Thread.sleep(3000);

        //提交订单按钮
        driver.findElement(By.cssSelector("body > div.body-content-container > div.body-content-formal-container > div:nth-child(5) > div > div.am-background-white.am-radius.am-padding-bottom-main > div.buy-nav-footer.am-padding-horizontal-main > div > form > div > button")).click();
        //屏幕截图
        Thread.sleep(1000);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
}
